﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Soapi.Notify2.Tests
{

    using System.IO;
    using System.Runtime.Serialization.Formatters.Binary;

    public static class SerializationTester
    {
        public static T RoundTrip<T>(T value) where T : class
        {
            if (value == null)
                throw new ArgumentNullException("value");

            using (var stream = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, value);

                stream.Seek(0, SeekOrigin.Begin);

                return (T)formatter.Deserialize(stream);
            }
        }
    }
}
